<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
<head>
<meta charset="UTF-8">
<title>我的账户-邮箱找回密码</title>
<jsp:include page="/include/wchat/head.jsp"></jsp:include>

<link type="text/css" rel="stylesheet" href="/v2/wchat/resrc/css/account.css">
<script type="text/javascript">

/**
 * 刷新验证码
 */
function refresh(str) {
	//$("#imgCaptcha").attr("src", environment.basePath + "/views/user/verifyCode.jsp?r=" + new Date().getTime());
	var timenow = new Date();
	$("#imgCaptcha").attr("src","I4008lOve893gOfUll983/imageCode.do?pageId="+str+"&d="+ timenow);
}

/**
 * 发送重置密码邮件
 */
function sendMail() {
	//手机号
	var $mail = $('#mail');
	//验证码
	var $captcha = $('#captcha');
	//信息提示
	var $errorMsg = $('#errorMsg');
	
	//检验邮箱
	if ($mail.val() == null || $mail.val() == '') {
    	$errorMsg.html('请输入邮箱').show();
    	return false;
	}
	var regMail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!regMail.test($mail.val())){
		$errorMsg.html('邮箱格式不正确，请检查并重新输入').show();
	    return false;
	}
	//检验验证码
	if ($captcha.val() == null || $captcha.val() == '') {
    	$errorMsg.html('请输入正确的验证码').show();
    	return false;
	}
	var param = {};
    param["paramMap.pageId"] = "resetPwd";
    param["paramMap.mail"] = $mail.val();
    param["paramMap.captcha"] = $captcha.val();
	
	//异步请求
	$.ajax({
		type: 'POST',
		url: environment.basePath + "/sendMail4ResetPwd.do",
		data: param,
		success: function(data) {
			//错误等信息提示
			if(data.code < 0){
				$errorMsg.html(data.msg).show();
				return false;
			}
			
			//跳转验证页面
			window.location.href = environment.basePath + "/resetPwdSuccessByMail.do";
		}
	});//End...$.ajax
}
</script>
</head>
<body>
<div id="header"> 
	<a href="javascript:history.go(-1);" class="backto">返回</a>
	<div class="title-sub">找回密码</div>
</div>
<div id="wrap">
	<div class="findpwd">
		<div class="link-touch">
			<ul class="items">
				<li>
					<label class="txt">邮箱</label>
					<input type="text" id="mail" class="input" placeholder="请输入邮箱">
				</li>
			</ul>
		</div>
		<div class="link-touch verify-num"> 
			<span class="verify-code">
				<input type="text" id="captcha" class="input" placeholder="请输入验证码" maxlength="4">
			</span> 
			<img id="imgCaptcha" src="I4008lOve893gOfUll983/imageCode.do?pageId=resetPwd" onclick="return refresh('resetPwd');" />
			<div id="errorMsg" class="vtip errs none">账号与密码不匹配，请重新输入</div>
		</div>
		<div class="operate-button operate-acc"> 
			<a href="javascript:;" class="btn" onclick="return sendMail();">发送重置密码邮件</a> 
			<a href="/inputMobile4ResetPwd.do" class="btn-server">使用绑定手机找回密码</a>
		</div>
	</div>
</div>

<jsp:include page="/include/wchat/footer.jsp"></jsp:include>
</body>
</html>